<template>
  <j-modal
    switchFullscreen
    title="订单审核"
    :visible="visible"
    @ok="handleOk"
    @cancel="handleCancel"
    width=70%
  >
    <div class="firstLine">
      <!--      基本信息-->
      <div class="essential">
        <div class="essential_text">基本信息</div>
        <a-form :form="form">
          <a-row :gutter="24">
            <!--            门店名称-->
            <a-col :md="12" :sm="24">
              <a-form-item
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                label="门店名称"
              >
                <app-stores placeholder="请选择门店" v-decorator="['terminalCode', validatorRules.terminalCode]">
                </app-stores>
              </a-form-item>
            </a-col>
            <!--            支付方式-->
            <a-col :md="12" :sm="24">
              <a-form-item
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                label="支付方式"
                >
                <cn-dict-select-tag placeholder="请选择支付方式" dict-code="pay_ment" triggerChange @change="handleChangePay"
                                   v-model="queryParam.payment"/>
              </a-form-item>
            </a-col>
            <!--            配送地址-->
            <a-col :md="12" :sm="24">
              <a-form-item
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                label="配送地址"
                >
                <cn-dict-select-tag placeholder="请选择支付方式" dict-code="pay_ment" triggerChange @change="handleChangePay"
                                   v-model="queryParam.payment"/>
              </a-form-item>
            </a-col>
            <!--          联系人-->
            <a-col :md="12" :sm="24">
              <a-form-item
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                label="联系人"
                >
                <a-input placeholder="请输入联系人" v-decorator="['linkman', validatorRules.linkman]"/>
              </a-form-item>
            </a-col>
            <!--          联系电话-->
            <a-col :md="12" :sm="24">
              <a-form-item
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                label="联系电话"
                >
                <a-input placeholder="请输入联系电话" v-decorator="['telephone', validatorRules.telephone]"/>
                <!--          <a-date-picker showTime format="YYYY-MM-DD HH:mm:ss" v-decorator="[ 'punchTime', {}]" />-->
              </a-form-item>
            </a-col>
          </a-row>
        </a-form>
      </div>
      <!--      订货信息-->
      <div class="essential">
        <div class="essential_text">订货信息</div>
        <a-table :columns="columns" :data-source="dataSource">
        </a-table>
      </div>
    </div>
  </j-modal>
</template>

<script>
import JInput from '@/components/cn-form/JInput.vue'
// import appStores from '@/views/mdm/couponStore/modules/appStores'

export default {
  name: 'OrderBehalf',
  components: { appStores },
  data() {
    return {
      visible: false,
      dataSource: [],
      form: this.$form.createForm(this),
      labelCol: {
        xs: { span: 24 },
        sm: { span: 6 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      modal: {},
      queryParam: {},
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '商品编号',
          align: 'center',
          dataIndex: 'productCode'
        },
        {
          title: '商品名称',
          align: 'center',
          dataIndex: 'productName'
        },
        {
          title: '单位',
          align: 'center',
          dataIndex: 'saleUnit'
        },
        {
          title: '单位',
          align: 'center',
          dataIndex: 'saleUnit'
        },
      ],
      validatorRules: {
        telephone: {
          rules: [
            { required: true, message: '', trigger: 'submit' },
            {
              validator: function(rule, value, callback) {
                if (!isMobile(value)) {
                  callback(new Error(''))
                }
                callback()
              }
            }
          ]
        },
        linkman: { required: true, message: '', trigger: 'submit' },
        terminalName: { required: true, message: '', trigger: 'submit' }
      },
    }
  },
  methods: {
    edit(record) {
      this.$nextTick(() => {
          this.form.setFieldsValue({
            terminalName: '',
            telephone: '',
            linkman: '',
            terminalCode:'',
          })
        }
      )
      console.log(record)
      this.visible = true
    }
    ,
    // 选择支付方式
    handleChangePay(value) {
      this.$set(this.queryParam, 'payment', value)
    }
    ,
    handleOk() {
      this.handleCancel()
    }
    ,
    handleCancel() {
      this.visible = false
    }
  }
}
</script>

<style scoped>
.firstLine {
  padding: 0 3%;
}

.essential_text {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}

.essential {
  border-bottom: 1px dashed #eae2e2;
  padding: 10px 0;
  margin-bottom: 10px;
}
</style>